package one;

import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.Arrays;
import java.util.Random;
import java.util.Scanner;

import javax.xml.transform.Templates;


public class Main {
	
	/* д */
	public static String generatePwd(String str, int n, int mode, int seed) {
		int k=0;
		String string = new String();
		//System.out.println(random);
		if(mode==1) {
			for (int i = 0; i < str.length(); i++) {
				Random  random=new Random();
				int args1=random.nextInt(n);
				//string =str[args1];
				//System.out.println(args1);
				
		    }
		}
		else {
			String[] temp=null;
			for (int i = 0; i < str.length(); i++) {
				Random  random=new Random();
				int args1=random.nextInt(n);
				String arr=null;
				System.out.println(args1);
				arr=str.substring(args1,args1+1);
				//System.out.println(arr);
			
				temp[i]=arr;
		   }
			for (int i = 0; i < n; i++) {
				str+=temp[i];
			}
		}
		return str;
	
	}
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String str = sc.next();
		int n = sc.nextInt();
		int mode = sc.nextInt();
		int seed = sc.nextInt();

		System.out.println(generatePwd(str, n, mode, seed));
        System.out.println("Ohhhhhhhhhhhhh");

		sc.close();
	}

	
	}


